home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
game
/
misc
/
8queens.lha
/
8Queens
(
.txt
)
next >
Wrap
AmigaBASIC Source Code
|
1997-06-08
|
5KB
|
239 lines
CLS
REM ***************************************************************
REM ***************************************************************
REM ***************************************************************
REM **** 8 Damen Problem © 1997 Klaus Häfner ****
REM **** 1299852 Stellungen werden gecheckt auf touch-free ****
REM ***************************************************************
DIM brett(8,8)
GOSUB drawbrett
d1x=1:d2x=2:d3x=3:d4x=4:d5x=5:d6x=6:d7x=7:d8x=8
d1y=8:d2y=8:d3y=8:d4y=8:d5y=8:d6y=8:d7y=8:d8y=8
stell=0
z$=TIME$
GOSUB drawfigures
LOCATE 14,1
PRINT "Getestete Stellungen :"
PRINT "Treffer in dieser Stellung :"
PRINT "Zeit :"
PRINT "Startzeit :"
REM ***************************************************************
REM Hauptschleife *************************************************
teil1:
FOR dame1=8 TO 1 STEP -1
d1y=dame1
GOSUB teil2
NEXT dame1
GOTO schluss
teil2:
FOR dame2=8 TO 1 STEP -1
d2y=dame2
GOSUB teil3
NEXT dame2
RETURN
teil3:
FOR dame3=8 TO 1 STEP -1
d3y=dame3
GOSUB teil4
NEXT dame3
RETURN
teil4:
FOR dame4=8 TO 1 STEP -1
d4y=dame4
GOSUB checkit
GOSUB killfigures
GOSUB drawfigures
IF hit=0 THEN GOTO schluss
GOSUB teil5
NEXT dame4
RETURN
teil5:
FOR dame5=8 TO 1 STEP -1
d5y=dame5
GOSUB teil6
NEXT dame5
RETURN
teil6:
FOR dame6=8 TO 1 STEP -1
d6y=dame6
GOSUB teil7
NEXT dame6
RETURN
teil7:
FOR dame7=8 TO 1 STEP -1
d7y=dame7
GOSUB teil8
NEXT dame7
RETURN
teil8:
FOR dame8=8 TO 1 STEP -1
d8y=dame8
GOSUB checkit
GOSUB killfigures
GOSUB drawfigures
IF hit=0 THEN GOTO schluss
stell=stell+1
LOCATE 14,31:PRINT stell
LOCATE 15,31:PRINT hit
LOCATE 16,32:PRINT TIME$
LOCATE 17,32:PRINT z$
NEXT dame8
RETURN
REM ***************************************************************
REM programmende **************************************************
schluss:
END
drawbrett:
FOR loop=10 TO 90 STEP 10
LINE (110,loop)-(270,loop)
NEXT loop
FOR loop=110 TO 270 STEP 20
LINE (loop,10)-(loop,90)
NEXT loop
RETURN
drawfigures:
REM Stellungsmerker löschen
FOR loop=1 TO 8
FOR lips=1 TO 8
brett(loop,lips)=0
NEXT lips,loop
REM Figuren ins feld "circlen"
cx=d1x
cy=d1y
GOSUB throwit
cx=d2x
cy=d2y
GOSUB throwit
cx=d3x
cy=d3y
GOSUB throwit
cx=d4x
cy=d4y
GOSUB throwit
cx=d5x
cy=d5y
GOSUB throwit
cx=d6x
cy=d6y
GOSUB throwit
cx=d7x
cy=d7y
GOSUB throwit
cx=d8x
cy=d8y
GOSUB throwit
RETURN
throwit:
brett(cx,cy)=1
x=(cx*20)+100
y=(cy*10)+5
CIRCLE (x,y),6,2
RETURN
REM ****************************************************************
checkit:
hit=0
FOR loop=1 TO 8:REM X
FOR lips=1 TO 8:REM Y
IF brett(loop,lips)=1 THEN GOSUB checkit2
NEXT lips,loop
RETURN
checkit2:
cx=loop:cy=lips
REM ********************* rechts unten checken
checkru:
cx=cx+1
cy=cy+1
IF cx>8 THEN GOTO checkr
IF cy>8 THEN GOTO checkr
IF brett(cx,cy)=1 THEN hit=hit+1:GOTO checkdone
GOTO checkru
REM ********************* rechts checken
checkr:
cx=loop:cy=lips
checkr2:
cx=cx+1
IF cx>8 THEN GOTO checkro
IF brett(cx,cy)=1 THEN hit=hit+1:GOTO checkdone
GOTO checkr2
REM ********************* rechts oben checken
checkro:
cx=loop:cy=lips
checkro2:
cx=cx+1
cy=cy-1
IF cx>8 THEN GOTO checklo
IF cy<1 THEN GOTO checklo
IF brett(cx,cy)=1 THEN hit=hit+1:GOTO checkdone
GOTO checkro2
REM ********************* links oben checken
checklo:
cx=loop:cy=lips
checklo2:
cx=cx-1
cy=cy-1
IF cx<1 THEN GOTO checkl
IF cy<1 THEN GOTO checkl
IF brett(cx,cy)=1 THEN hit=hit+1:GOTO checkdone
GOTO checklo2
REM ********************* links checken
checkl:
cx=loop:cy=lips
checkl2:
cx=cx-1
IF cx<1 THEN GOTO checklu
IF brett(cx,cy)=1 THEN hit=hit+1:GOTO checkdone
GOTO checkl2
REM ********************* links unten checken
checklu:
cx=loop:cy=lips
checklu2:
cx=cx-1
cy=cy+1
IF cx<1 THEN GOTO checkdone
IF cy>8 THEN GOTO checkdone
IF brett(cx,cy)=1 THEN hit=hit+1:GOTO checkdone
GOTO checklu2
REM ********************* Fertig mit checken!!!!
checkdone:
RETURN
killfigures:
cx=d1x
cy=d1y
GOSUB throwit2
cx=d2x
cy=d2y
GOSUB throwit2
cx=d3x
cy=d3y
GOSUB throwit2
cx=d4x
cy=d4y
GOSUB throwit2
cx=d5x
cy=d5y
GOSUB throwit2
cx=d6x
cy=d6y
GOSUB throwit2
cx=d7x
cy=d7y
GOSUB throwit2
cx=d8x
cy=d8y
GOSUB throwit2
RETURN
throwit2:
cy=cy+1
x=(cx*20)+100
y=(cy*10)+5
CIRCLE (x,y),6,0
IF cy=9 THEN GOTO throwit3
RETURN
throwit3:
cy=1
x=(cx*20)+100
y=(cy*10)+5
CIRCLE (x,y),6,0
RETURN